package com.spider.utils;

import java.util.Comparator;

import org.jsoup.nodes.Element;
/**
 * 重写comapator
 * @author Shan
 *
 * @param <T>
 */
public class ElementsComparator<T> implements Comparator<T> {

	
	private Integer getId(T elements){
		Element ele = (Element)elements;
		String url = ele.attr("href");
		String str_id = url.substring(url.indexOf("id=")+3,url.indexOf("&"));
		return Integer.parseInt(str_id);
	}

	@Override
	public int compare(T o1, T o2) {
		return getId(o2) - getId(o1);
	}

}
